import { App, Modal, Plugin, Setting, Notice } from 'obsidian';
import DailyNotesMergePlugin from "./main";
import {CommonRecursivelyJobUI, CommonSingleJobUI, GeneralUI} from "./common";

export class ExecuteUI extends Modal {
    plugin: DailyNotesMergePlugin;
    generalUI: GeneralUI;
    commonSingleJobUI: CommonSingleJobUI;
    commonRecursivelyJobUI: CommonRecursivelyJobUI;

  constructor(app: App, plugin: DailyNotesMergePlugin) {
    super(app);
    this.plugin = plugin;
    this.generalUI = new GeneralUI(this.contentEl, plugin);
    this.commonSingleJobUI = new CommonSingleJobUI(this.contentEl, plugin);
    this.commonRecursivelyJobUI = new CommonRecursivelyJobUI(this.contentEl, plugin);

  }

  onOpen() {
      this.contentEl.empty();
      this.generalUI.display();
      this.commonSingleJobUI.display();
      new Setting(this.contentEl).addButton((cb) => {
          cb.setButtonText("Execute all Single Jobs")
              .setCta()
              .onClick(async () => {
                await this.plugin.executeAllSingleJobs(this.plugin.settings.jobs);
              });
      })
      this.commonRecursivelyJobUI.display();
  }
}